package com.seamtop.cuber.core;

import com.seamtop.cuber.common.conf.CuberServerConfiger;
import io.searchbox.client.JestClient;
import io.searchbox.client.JestClientFactory;
import io.searchbox.client.config.HttpClientConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Created by feng on 2015/9/3.
 */
public class ESManager {

    private static final Logger LOG = LoggerFactory.getLogger(ESManager.class);

    private static String connectionUrl = CuberServerConfiger.serverConfigProperties.getProperty("search.server");

    public static JestClient getClient(){
        JestClientFactory factory = new JestClientFactory();
        factory.setHttpClientConfig(new HttpClientConfig.Builder(connectionUrl)
                .multiThreaded(true).build());
        JestClient client = factory.getObject();
        LOG.info("Get ES client -- url:"+connectionUrl + " client:"+client);
        return client;
    }
}
